<template>
  <div class="header">
    <span class="header-time">{{time}}</span>
    <div class="title"></div>
    <span class="header-area">2°C 金华市</span>
    <!-- <div class="tuxing">
      <div class="tuxing-item2"></div>
      <div class="tuxing-item"></div>
    </div> -->
  </div>
</template>

<script>
let timer = null;
export default {
  name: 'header-view',
  data () {
    return {
      time: ''
    }
  },
  mounted () {
    this.setTimer();
  },
  destroyed () {
    if (timer) {
      clearInterval(timer);
      timer = null;
    }
  },
  methods: {
    setTimer () {
      if (!timer) {
        timer = setInterval(() => {
          this.time = new Date().toLocaleString();
        }, 1000);
      }

    }
  }
}
</script>

<style lang="scss" scoped>
.header {
  background-image: url('@/assets/images/header-bg.png');
  background-size: 100% 100%;
  width: 100%;
  height: 100px;

  position: relative;

  // display: flex;
  // // justify-content: center;
  // align-items: center;
  // justify-content: space-around;

  .header-time {
    position: absolute;
    top: 36px;
    left: 42px;
    font-size: 18px;
    color: rgba(230, 247, 255, 0.64);
    line-height: 24px;
  }

  .title {
    position: absolute;
    top: 21px;
    left: 50%;
    transform: translateX(-50%);
    // margin-top: 21px;
    background-image: url('@/assets/images/title.png');
    background-size: 100% 100%;
    width: 619px;
    height: 36px;
  }

  .header-area {
    position: absolute;
    right: 42px;
    top: 36px;
    font-size: 18px;
    color: rgba(230, 247, 255, 0.64);
    line-height: 24px;
  }

  .tuxing {
    position: absolute;
    top: 200px;
    left: 500px;
    width: 135px;
    height: 35px;
    background: #01192a;
    box-shadow: 0px 17px 5px 0px rgba(17, 34, 82, 0.48);
    // opacity: 0.5;
    border: 1px solid;
    border-image: linear-gradient(
        270deg,
        rgba(86, 213, 240, 0),
        rgba(86, 213, 240, 1)
      )
      1 1;

    display: flex;
    flex-direction: row;
    .tuxing-item2 {
      width: 42px;
      height: 100%;
      background-color: rgba(255, 197, 61, 1);
    }
    .tuxing-item {
      // width: 42px;
      // height: 35px;
      // margin-left: 110px;
      border-width: 19px;
      border-color: transparent transparent transparent rgba(255, 197, 61, 1);
      border-style: dotted dotted dotted solid;
    }
  }
}
</style>